<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>请求运行一条 FTP 命令</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.ftp-delete.html">ftp_delete</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ftp-fget.html">ftp_fget</a></div>
 <div class="up"><a href="ref.ftp.html">FTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.ftp-exec" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">ftp_exec</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.0.3, PHP 5)</p><p class="refpurpose"><span class="refname">ftp_exec</span> &mdash; <span class="dc-title">请求运行一条 FTP 命令</span></p>

   </div>
   <div class="refsect1 unknown-examplet" id="refsect1-function.ftp-exec-unknown-examplet">
    <h3 class="title">说明</h3>
    <div class="methodsynopsis dc-description">
     <span class="type">bool</span> <span class="methodname"><strong>ftp_exec</strong></span>
      ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$ftp_stream</code></span>
     , <span class="methodparam"><span class="type">string</span> <code class="parameter">$command</code></span>
     )</div>

    <p class="para rdfs-comment">
     发送一个 SITE EXEC <em><code class="parameter">command</code></em> 请求到 FTP
     服务器。如果成功（服务器发送响应代码 <em>200</em>）则返回
     <strong><code>TRUE</code></strong>，否则返回 <strong><code>FALSE</code></strong>。
    </p>
    <p class="para">
     <div class="example" id="example-4190">
      <p><strong>Example #1 <span class="function"><strong>ftp_exec()</strong></span> 例子</strong></p>
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$command&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'ls&nbsp;-al'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_id&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ftp_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp_server</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$login_result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ftp_login</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$ftp_user_name</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$ftp_user_pass</span><span style="color: #007700">);<br />if(</span><span style="color: #0000BB">$res&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ftp_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn_id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$command</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$command</span><span style="color: #DD0000">&nbsp;executed&nbsp;successfully&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">nl2br</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">);<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'could&nbsp;not&nbsp;execute&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$command</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
      </div>

     </div>
    </p>
    <p class="para">
     参见 <span class="function"><a href="function.ftp-raw.html" class="function">ftp_raw()</a></span>。
    </p>
   </div>

  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.ftp-delete.html">ftp_delete</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ftp-fget.html">ftp_fget</a></div>
 <div class="up"><a href="ref.ftp.html">FTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
